<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <a href="/addnews">添加</a>

  <p>
    <% if(username) { %>
    <a href="/logout">退出登录</a>
    <a href="/user">个人中心</a>
    <%}else{%>
    <a href="/login">登录</a>
    <a href="/register">注册</a>
 <% }%>
  </p>
  <ul>
    <% data.forEach(item=>{%>
      <li>
        <a href="/detail/<%=item.id%>">
          <%=item.title%>
        </a>
        <a href="/update?id=<%=item._id%>">编辑</a>
        <a href="/delnews/<%=item._id%>">删除</a>
      </li>
      <% }) %>
  </ul>
</body>

</html>